package 双指针.两数之和输入有序数组167;

import utils.Utils;

public class Solution {

    public static int[] twoSum(int[] numbers, int target) {
        int i = 0;
        int j = numbers.length - 1;
        while(i < j){
            if(numbers[i] + numbers[j] > target){
                j--;
            }else if(numbers[i] + numbers[j] < target){
                i++;
            }else{
                return new int[]{i+1,j+1};
            }
        }
        return null;
    }

    public static void main(String[] args) {
        int[] numbers = {2,7,11,15};
        int target = 9;
        Utils.printIntArr(twoSum(numbers,target));
    }
}
